import { setUser } from '../../utils/storage';

Component({
  methods: {
    onLogin() {
      wx.getUserProfile({
        desc: '用于展示个人中心',
        success: (res) => {
          const user = res.userInfo;
          setUser(user);
          wx.showToast({ title: '登录成功', icon: 'success' });
          setTimeout(() => wx.navigateBack(), 400);
        },
        fail: () => {
          wx.showToast({ title: '已取消授权', icon: 'none' });
        }
      });
    }
  }
});